package com.example.tcpLearn.tcp1;

import java.net.Socket;

public class printInformation {

    public static void print(Socket socket) {
        System.out.println("获取远程端地址" + socket.getInetAddress()); // 获取远程端地址：/127.0.0.1
        System.out.println("获取本机地址" + socket.getLocalAddress()); // 获取本机地址
        System.out.println("获取远程端口号" + socket.getPort()); // 获取远程端口号：8888
        System.out.println("获取本机端口号" + socket.getLocalPort()); // 获取本机端口号
        System.out.println("获取远程端主机名" + socket.getRemoteSocketAddress()); // 获取远程端主机名：/127.0.0.1:8888
        System.out.println("获取本地主机名" + socket.getLocalSocketAddress()); // 获取本地主机名
    }

}
